package com.video4s.utils;
 
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.SimpleDateFormat;
import java.util.Collection;
 
 
 
 
 
 
 
 
 public class Utils
 {
/*  90 */   private static final char[] HEXES = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
 
/* 152 */   public static SimpleDateFormat dateFormat1 = new SimpleDateFormat("ddMMyyyy");
/* 153 */   public static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
/* 154 */   public static SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 
   public static boolean isNumberic(Object value)
   {
/*  15 */     if (value == null)
/*  16 */       return false;
     try
     {
/*  19 */       Long.parseLong(value.toString());
/*  20 */       return true; } catch (NumberFormatException ex) {
     }
/*  22 */     return false;
   }
 
   public static int min(int[] values)
   {
/*  27 */     int min = 2147483647;
/*  28 */     for (int v : values) {
/*  29 */       if (v < min) {
/*  30 */         min = v;
       }
     }
/*  33 */     return min;
   }
 
   public static int sum(int[] values) {
/*  37 */     int sum = 0;
/*  38 */     for (int i : values) {
/*  39 */       sum += i;
     }
/*  41 */     return sum;
   }
 
   public static void deepCopy(int[][][] source, int[][][] dest) {
/*  45 */     for (int i = 0; i < source.length; i++)
/*  46 */       for (int j = 0; j < source[i].length; j++)
/*  47 */         for (int k = 0; k < source[i][j].length; k++)
/*  48 */           dest[i][j][k] = source[i][j][k];
   }
 
   public static String urlEncode(String url)
   {
     try
     {
/*  56 */       return URLEncoder.encode(url, "UTF-8");
     } catch (UnsupportedEncodingException e) {
/*  58 */       throw new RuntimeException("never!!!", e);
     }
   }
 
   public static String urlDecode(String url) {
     try {
/*  64 */       return URLDecoder.decode(url, "UTF-8");
     } catch (UnsupportedEncodingException e) {
/*  66 */       throw new RuntimeException("never!!!", e);
     }
   }
 
   public static boolean isNull(Object[] objects) {
/*  71 */     for (Object object : objects) {
/*  72 */       if (object != null) {
/*  73 */         return false;
       }
     }
/*  76 */     return true;
   }
 
   public static int hashCode(long value) {
/*  80 */     return (int)(value ^ value >>> 32);
   }
 
   public static boolean isEmpty(Collection<?> coll) {
/*  84 */     return (coll == null) || (coll.isEmpty());
   }
 
   public static boolean isNotEmpty(Collection<?> coll) {
/*  88 */     return (coll != null) && (coll.size() > 0);
   }
 
   public static String getHex(byte[] raw)
   {
/*  94 */     if (raw == null) {
/*  95 */       return null;
     }
/*  97 */     char[] hex = new char[2 * raw.length];
/*  98 */     int i = 0; for (int j = 0; i < raw.length; i++) {
/*  99 */       byte b = raw[i];
/* 100 */       hex[(j++)] = HEXES[((b & 0xF0) >> 4)];
/* 101 */       hex[(j++)] = HEXES[(b & 0xF)];
     }
/* 103 */     return new String(hex);
   }
 
   public static String md5(String x) {
     try {
/* 108 */       MessageDigest md5 = MessageDigest.getInstance("MD5");
/* 109 */       byte[] digest = md5.digest(x.getBytes());
/* 110 */       return getHex(digest);
     }
     catch (NoSuchAlgorithmException e) {
/* 113 */       throw new RuntimeException("never!", e);
     }
   }
 
   public static String toUrlFriendly(String b)
   {
/* 119 */     String a = b.toLowerCase().trim();
/* 120 */     a = a.replaceAll("(à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ)", "a");
/* 121 */     a = a.replaceAll("(è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ)", "e");
/* 122 */     a = a.replaceAll("(ì|í|ị|ỉ|ĩ)", "i");
/* 123 */     a = a.replaceAll("(ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ)", "o");
/* 124 */     a = a.replaceAll("(ù|ú|ụ|ủ|ũ|ư|ừ|ứ|ự|ử|ữ)", "u");
/* 125 */     a = a.replaceAll("(ỳ|ý|ỵ|ỷ|ỹ)", "y");
/* 126 */     a = a.replaceAll("(đ)", "d");
/* 127 */     a = a.replaceAll("(À|Á|Ạ|Ả|Ã|Â|Ầ|Ấ|Ậ|Ẩ|Ẫ|Ă|Ằ|Ặ|Ẳ|Ẵ)", "A");
/* 128 */     a = a.replaceAll("(È|É|Ẹ|Ẻ|Ẽ|Ê|Ề|Ế|Ệ|Ể|Ễ)", "E");
/* 129 */     a = a.replaceAll("(Ì|Í|Ị|Ỉ|Ĩ)", "I");
/* 130 */     a = a.replaceAll("(Ò|Ó|Ọ|Ỏ|Õ|Ô|Ồ|Ố|Ộ|Ổ|Ỗ|Ơ|Ờ|Ợ|Ở|Ỡ)", "O");
/* 131 */     a = a.replaceAll("(Ù|Ú|Ụ|Ủ|Ũ|Ư|Ừ|Ứ|Ự|Ử|Ữ)", "U");
/* 132 */     a = a.replaceAll("(Ỳ|Ý|Ỵ|Ỷ|Ỹ)", "Y");
/* 133 */     a = a.replaceAll("(Đ)", "D");
/* 134 */     a = a.replaceAll("( )", " ");
/* 135 */     a = a.replaceAll("&", " ");
/* 136 */     a = a.replaceAll("!|\"|#|\\$|%|\\*|\\+|,|:|<|=|>|\\?|@|\\|\\||'|/|~|_|;|\\(|\\)|\\{|\\}", "");
/* 137 */     a = a.replaceAll("“|”", "");
/* 138 */     a = a.replaceAll("\\[|\\]", "");
/* 139 */     a = a.replaceAll("\\.", "");
/* 140 */     a = a.replaceAll("\\^|\\`", "");
/* 141 */     a = a.replaceAll("’|́|̃|̉|̀|́", "");
/* 142 */     a = a.replaceAll(" ", "-");
/* 143 */     a = a.replaceAll("  ", "-");
/* 144 */     a = a.replaceAll("   ", "-");
/* 145 */     a = a.replaceAll("--", "-");
/* 146 */     a = a.replaceAll("---", "-");
/* 147 */     a = a.replaceAll("----", "-");
/* 148 */     a = a.replaceAll("-----", "-");
 
/* 150 */     return a;
   }
 
   public static void main(String[] args)
   {
/* 156 */     System.out.println(toUrlFriendly("V.NB - HN.T&T: Chiến thắng xứng đáng"));
   }
 }